// LinkedList.cpp : Defines the entry point for the console application.


#include "stdio.h"
#include "stdlib.h"
#include "string.h"




int PrintTelephoneWords(int phoneNumber[], char letters[10][4], char out[], int length, int level)
{
	int i;
	
	if(level == length){
		printf("%s\n", out);
		return 0;
	}

	if(phoneNumber[level] > 1 && phoneNumber[level] <=9){

		for(i=0; i<3; i++){

			out[level] = letters[phoneNumber[level]][i];
			PrintTelephoneWords(phoneNumber, letters, out, length, level + 1);		
		}
	}
	else{

		out[level] = phoneNumber[level] + '0';
		PrintTelephoneWords(phoneNumber, letters, out, length, level + 1);
	}
	

	return 0;
}


int main(int argc, char* argv[])
{
	unsigned int l;

	char letters[10][4] = { "000", "111", "ABC", "DEF", "GHI", "JKL", "MNO", "PRS", "TUV", "WXY"};
	
	int phoneNumber[] = {8,6,6,2,6,6,5};
	
	l = 7;

	char *out = (char*)malloc(sizeof(char) * (l+1));

	out[l] = '\0';

	
	PrintTelephoneWords(phoneNumber, letters, out, l, 0);
		
	return 0;
}

